{eq name="$Request.action" value="edit"}
{Data:article name="Role" id="request" var="vo"}
{/eq}
<style>
	.layui-tree li .layui-tree-spread, .layui-tree li a{height:30px;}
	.layui-tree li a i{padding:0;}
	.layui-tree li {padding-left: 22px;}
	.layui-tree li>i {margin-left: -22px;}
	.layui-form-item .layui-tree li .layui-form-checkbox {margin:0;}
	.layui-form-item .layui-tree li .layui-form-checkbox i{color:#fff;}
</style>
<form action="__APP__/Role/update.html" class="child-form page-list-form layui-form layui-form-pane" method="post">
	<div class="layui-form-item">
		<label class="layui-form-label">角色名称</label>
		<div class="layui-input-inline input-6x">
			<input type="text" class="layui-input" name="title" value="{$vo.title|default=''}" autocomplete="off" placeholder="请填写标题" />
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">权限列表</label>
		<div class="layui-input-inline input-6x" style="width:800px;">
			<div id="tree"></div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">状态</label>
		<div class="layui-input-inline input-6x">
			<input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="启用|禁用" {neq name="vo.status" value="0"}checked{/neq} >
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-inline input-6x">
			<button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit">提交</button>
		</div>
	</div>
	<input type="hidden" name="id" value="{$vo.id|default=''}" />
</form>
<script type="text/html" id="RuleListVo">
	{$RuleList|json_encode}
</script>
<script type="text/javascript">
	layui.use(['jquery','ruletree','form'],function(){
		var $ = layui.jquery,
			jsontxt = $('#RuleListVo').html().replace(/"title":/ig,function(){return '"name":';}),
			rule=$.parseJSON('{$vo.rules|json_encode}');
		layui.ruletree({
			elem: '#tree',
			nodes: $.parseJSON(jsontxt),
			click: function(node){
				console.log(node) //node即为当前点击的节点数据
			} 
		});
		for(var i in rule){
			$(':checkbox[value='+rule[i]+']').get(0).checked = true;
		}
		layui.form.render('checkbox');
	});
</script>